//
//  ThreeButtonAddView.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/12.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//
// button.titleEdgeInsets = UIEdgeInsetsMake(71, -button.titleLabel.bounds.size.width-50, 0, 0);//设置title在button上的位置（上top，左left，下bottom，右right）  
#import "ThreeButtonAddView.h"
#import "CommonMacro.h"

@interface ThreeButtonAddView ()
@property (nonatomic,strong) UIButton *integralCenterButton;
@property (nonatomic,strong) UIButton *specialButton;
@property (nonatomic,strong) UIButton *freeTrailButton;
@property (nonatomic,strong) UILabel *integralCenterLabel;
@property (nonatomic,strong) UILabel *specialLabel;
@property (nonatomic,strong) UILabel *freeTrailLabel;
@end
@implementation ThreeButtonAddView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self addSubViews];
    }
    return self;
}

#pragma mark 添加视图
- (void)addSubViews
{
        CGFloat buttonX = 0;
        CGFloat buttonY = 0;
        CGFloat buttonW = SCREEN_WIDTH/3;
        CGFloat buttonH = 50;
        CGFloat MargginTop = 65;
    
        //1.积分中心
    self.integralCenterButton = [[UIButton alloc] initWithFrame:CGRectMake(buttonX,buttonY ,buttonW ,buttonH)];
    [self.integralCenterButton setImage:[UIImage imageNamed:@"积分中心"]  forState:UIControlStateNormal];
    self.integralCenterButton.tag = 1000;
    [self.integralCenterButton setTitle:@"积分中心" forState:UIControlStateNormal];
    self.integralCenterButton.imageEdgeInsets = UIEdgeInsetsMake(5, 40, 0, 0);
    self.integralCenterButton.titleEdgeInsets = UIEdgeInsetsMake(MargginTop, 0, 0, 0);
    [self.integralCenterButton.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [self.integralCenterButton setTitleColor:UIColorWithRGBA(150, 150, 150, 1) forState:UIControlStateNormal];
    [self addSubview:self.integralCenterButton];
    [self.integralCenterButton addTarget:self action:@selector(clickThreeButton:) forControlEvents:UIControlEventTouchUpInside];
    
        //2.专题
    self.specialButton = [[UIButton alloc] initWithFrame:CGRectMake(buttonW,buttonY, buttonW, buttonH)];
    [self.specialButton setImage:[UIImage imageNamed:@"专题"] forState:UIControlStateNormal];
    self.specialButton.tag = 1001;
    [self.specialButton setTitle:@"专题" forState:UIControlStateNormal];
        [self addSubview:self.specialButton];
     self.specialButton.imageEdgeInsets = UIEdgeInsetsMake(5, 25, 0, 0);
    self.specialButton.titleEdgeInsets = UIEdgeInsetsMake(MargginTop, -15, 0, 20);
    [self.specialButton.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [self.specialButton setTitleColor:UIColorWithRGBA(150, 150, 150, 1) forState:UIControlStateNormal];
    [self addSubview:self.specialButton];
    [self.specialButton addTarget:self action:@selector(clickThreeButton:) forControlEvents:UIControlEventTouchUpInside];
    
        //3.免费试用
        self.freeTrailButton = [[UIButton alloc] initWithFrame:CGRectMake(buttonW*2,buttonY, buttonW, buttonH)];
    [self.freeTrailButton setImage:[UIImage imageNamed:@"免费试用"] forState:UIControlStateNormal];
    self.freeTrailButton.tag = 1002;
    [self.freeTrailButton setTitle:@"免费试用" forState:UIControlStateNormal];
    [self addSubview:self.specialButton];
    self.freeTrailButton.titleEdgeInsets = UIEdgeInsetsMake(MargginTop, -60, 0, 20);
    [self.freeTrailButton.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [self.freeTrailButton setTitleColor:UIColorWithRGBA(150, 150, 150, 1) forState:UIControlStateNormal];
    [self addSubview:self.freeTrailButton];
    [self.freeTrailButton addTarget:self action:@selector(clickThreeButton:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)clickThreeButton:(UIButton *)button
{
    if ([self.threeButtonClickDelegate respondsToSelector:@selector(threeButtonClick:)]) {
        [self.threeButtonClickDelegate threeButtonClick:button];
    }
}

@end
